package JasPerl::JSTL::Fmt::TimeZoneWrapper;

use 5.010;
use strict;
use warnings;

use parent qw(DateTime::TimeZone);

sub new {
    my ($class, $tz) = @_;
    bless \$tz, $class;
}

sub name {
    return ${$_[0]}->get_id();
}

sub short_name_for_datetime {
    return ${$_[0]}->get_id();
}

sub offset_for_datetime {
    my ($self, $dt) = @_;
    my $date = JasPerl::Util::Date->from($dt);
    return ${$self}->get_offset($date) / 1000;
}

sub offset_for_local_datetime {
    my ($self, $dt) = @_;
    my ($rd_day, $rd_sec, $rd_nsec) = $dt->local_rd_values;
    # FIXME: using private method
    my @ymd = $dt->_rd2ymd($rd_day);
    # warn "ymd=@ymd";
    my $msec = int($rd_sec * 1000 + $rd_nsec / 1000000);
    return ${$self}->get_local_offset(@ymd, $msec) / 1000;
}

sub is_dst_for_datetime {
    my ($self, $dt) = @_;
    my $date = JasPerl::Util::Date->from($dt);
    return ${$self}->in_daylight_time($date);
}

sub has_dst_changes {
    return ${$_[0]}->use_daylight_time();
}

sub category {
}

sub is_floating {
}

sub is_olson {
}

sub is_utc {
}

1;
